package cn.SiFuLan.controls;

import cn.SiFuLan.dao.IbrandDao;
import cn.SiFuLan.dao.IclassifDao;
import cn.SiFuLan.dao.IspuDao;
import cn.SiFuLan.dao.impl.brandDaoImpl;
import cn.SiFuLan.dao.impl.classifDaoImpl;
import cn.SiFuLan.dao.impl.spuDaoImpl;
import cn.SiFuLan.entity.brandEntity;
import cn.SiFuLan.entity.classifyEntity;
import cn.SiFuLan.entity.spuEntity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/admin/update.shtml")
public class xiugaiServlt extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //brand下拉列表
        IbrandDao ibrandDao=new brandDaoImpl();
        List<brandEntity> brandlist=ibrandDao.All();
        //classif下拉列表
        IclassifDao iclassifDao=new classifDaoImpl();
        List<classifyEntity> classlist=iclassifDao.All();
        //spu
        IspuDao ispuDao=new spuDaoImpl();
        String spuid=request.getParameter("spuid");
        spuEntity spu=null;
        if (spuid!=null && !spuid.equals("")){
          spu =ispuDao.getall(Integer.parseInt(spuid));
        }
        request.setAttribute("brandlist",brandlist);
        request.setAttribute("classlist",classlist);
        request.setAttribute("spu",spu);
        request.getRequestDispatcher("update1.jsp").forward(request,response);
    }
}
